package com.laxia.exception.ensure.extensions;


import com.laxia.exception.ExceptionFactory;
import com.laxia.exception.ensure.EnsureParam;

import java.util.Collection;


public class EnsureParamCollectionExtension extends EnsureParam<Collection> {

    private Collection collection;

    public EnsureParamCollectionExtension(Collection collection) {
        super(collection);
        this.collection = collection;
    }

    public EnsureParamCollectionExtension isNotEmpty(String errMsg, Object... objects) {
        if (null == collection || collection.isEmpty()) {
            throw ExceptionFactory.create(errMsg, objects);
        } else {
            return this;
        }
    }

    public EnsureParamCollectionExtension isEmpty(String errMsg, Object... objects) {
        if (null != collection && collection.size() > 0) {
            throw ExceptionFactory.create(errMsg, objects);
        } else {
            return this;
        }
    }
}
